package net.gyapp.markim.module.contact.adapter;

import android.text.TextUtils;
import android.widget.ImageView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.easyder.wrapper.core.manager.ImageManager;

import net.gyapp.markim.R;
import net.gyapp.markim.core.entity.MemberEntity;
import net.gyapp.markim.module.basic.base.BaseRecyclerHolder;
import net.gyapp.markim.module.contact.vo.TempGroupBean;

import java.util.List;

/**
 * Auther:  winds
 * Email:   heardown@163.com
 * Date:    2018/8/4.
 * Desc:
 */

public class GroupMemberAdapter extends BaseQuickAdapter<Object, BaseRecyclerHolder> {
    public GroupMemberAdapter() {
        super(R.layout.item_group_member);
    }

    public void setAdapterData(List<MemberEntity> list) {
        mData.clear();
        mData.addAll(list);
        mData.add(new TempGroupBean(1, R.drawable.group_add));
        mData.add(new TempGroupBean(2, R.drawable.group_jianshao));
        notifyDataSetChanged();
    }

    @Override
    protected void convert(BaseRecyclerHolder helper, Object item) {
        if (item instanceof MemberEntity) {
            helper.setText(R.id.tv_name, TextUtils.isEmpty(((MemberEntity) item).nick) ? "暂无昵称" : ((MemberEntity) item).nick);
            ImageManager.load(mContext, ((ImageView) helper.getView(R.id.iv_image)), ((MemberEntity) item).avatar, R.drawable.placeholder_header);
        } else if (item instanceof TempGroupBean) {
            helper.setText(R.id.tv_name, null);
            helper.setImageResource(R.id.iv_image, ((TempGroupBean) item).imageId);
        }

    }
}
